package com.welsy.authoring.vo.course
{
	import com.welsy.authoring.vo.course.pattern.*;
	import com.welsy.authoring.business.CourseQNames;
	
	[Bindable]	
	public class ModuleVO extends CourseItem
	{
	  public var courseId:String = "";
	  public var moduleId:String = "";
	  public var type:String = "";
      public var title:String = "";
	  public var position:String = "";
	  public var notes:String = "";
	  public var displayFeedback:String = "true";	
		
	  // The array of child elements
      private var _items:Array;

      public function ModuleVO() {
         _items = new Array();
      }
      
      public function setProperties(list:XMLList):void {      	
     	var moduleId:String = list.child(CourseQNames.qnModuleID);
    	var moduleTitle:String = list.child(CourseQNames.qnTitle);	  
    	var modulePos:String = list.child(CourseQNames.qnPosition);
    	var moduleNotes:String = list.child(CourseQNames.qnModuleNotes);
        var moduleDisplayFeddback:String = list.child(CourseQNames.qnModuleDispalyFeedBack);
        this.moduleId = moduleId;
        this.title = moduleTitle;
        this.position = modulePos;
        this.notes = moduleNotes;
        this.displayFeedback = moduleDisplayFeddback;        
      }
     
      override public function addItem(item:ICourseItem):void {
         _items.push(item);
      }

      override public function removeItem(item:ICourseItem):void {
         var i:uint;
         // Loop through all the child elements.
         for(i = 0; i < _items.length; i++) {
            // If one of the elements matches the 
            // parameter remove it from the array.
            if(_items[i] == item) {
               _items.splice(i, 1);
               break;
            }
         }
      }
      
      public function removeAllItems():void {
      	//empty items array 
      	_items = new Array(0);
      }
      
      override public function iterator():ICourseIterator {
         
         return new ArrayCourseIterator(_items);
      }

	}
}